<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:th="http://www.thymeleaf.org">
<!--引入thymeleaf命名空间-->
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>人事管理系统</title>
  <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
  <link rel="stylesheet" th:href="@{/css/global.css}">
  <link rel="stylesheet" th:href="@{/icheck/minimal/red.css}">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!--引入导航栏-->
    <div th:replace="common/admin/common_top :: top"></div>
    <div th:replace="common/admin/common_left ::left"></div>

    <!-- 导入/model/list/*_model -->
    <div th:switch="${operation}">
        <div th:replace="model/list/employee_list_model :: employee_list_model"></div>
        <div th:replace="model/list/birthday_record_model :: birthday_record_model"></div>
        <div th:replace="model/list/certificate_info_model :: health_certificate_model"></div>
        <div th:replace="model/list/contract_sign_model :: contract_sign_model"></div>
        <div th:replace="model/list/employee_card_model :: employee_card_model"></div>
        <div th:replace="model/list/family_info_model :: family_info_model"></div>
        <div th:replace="model/list/free_charge_model :: free_charge_model"></div>
        <div th:replace="model/list/induction_info_model :: induction_info_model"></div>
        <div th:replace="model/list/professional_skill_model :: professional_skill_model"></div>
        <div th:replace="model/list/provident_fund_purchase_model :: provident_fund_purchase_model"></div>
        <div th:replace="model/list/purchase_insurance_model :: purchase_insurance_model"></div>
        <div th:replace="model/list/receive_training_model :: receive_training_model"></div>
        <div th:replace="model/list/retire_info_model :: retire_info_model"></div>
    </div>


  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>
<script type="text/javascript" th:src="@{/javascript/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/icheck/icheck.js}"></script>
<script type="text/javascript" th:src="@{/javascript/dw.js}"></script>
<!--layui的分页-->
<script>
    layui.use( 'laypage', function(){
        var laypage = layui.laypage;
        //当前页-1（从0开始）
        var currentPage = [[${currentPage}]];
        //总页数
        var totalPage=[[${totalPage}]];
        //获取当前所在列表的判断标识
        // var operation = [[${operation}]];

        //分页
        laypage.render({
            elem: 'pageDemo' //分页容器的id
            ,count: totalPage //从后台传过来的总页数
            ,skin: '#1E9FFF' //自定义选中色值
            ,limit: 3
            ,curr:currentPage    //从后台传过来的当前页数-1
            ,jump: function(obj, first){
                if(!first){
                    // 重定向到分页查询的接口
                    switch ('[[${operation}]]') {
                        case 'employee_list_model':
                            window.location.href = '/employee/emps/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'birthday_record_model':
                            window.location.href = '/BirthdayRecord/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'certificate_info_model':
                            window.location.href = '/CertificatesInfo/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'contract_sign_model':
                            window.location.href = '/ContractSign/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'employee_card_model':
                            window.location.href = '/EmployeeCard/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'family_info_model':
                            window.location.href = '/FamilyInfo/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'free_charge_model':
                            window.location.href = '/FreeCharge/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'induction_info_model':
                            window.location.href = '/InductionInfo/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'professional_skill_model':
                            window.location.href = '/ProfessionalSkills/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'provident_fund_purchase_model':
                            window.location.href = '/ProvidentFundPurchase/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'purchase_insurance_model':
                            window.location.href = '/PurchaseInsurance/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'receive_training_model':
                            window.location.href = '/ReceiveTraining/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        case 'retire_info_model':
                            window.location.href = '/RetireInfo/list/?currentPage='+obj.curr+'&limit='+obj.limit;
                            break;
                        default:
                            break;
                    }
                }
            }
        });

    });

</script>

<!-- 设置批量删除和页面刷新 -->
<script>
    layui.use(['element', 'layer'], function () {
        var element = layui.element;
        var layer = layui.layer;
        var $ = layui.jquery;

        // +----------------------------------------------------------------------
        // | icheck
        // +----------------------------------------------------------------------
        $('input').iCheck({
            checkboxClass: 'icheckbox_minimal-red',
            radioClass: 'iradio_minimal-red',
            increaseArea: '20%' // optional
        });//checkbox美化
        $('.selectAll input').on('ifChecked', function (event) {
            $('input').iCheck('check');
        });//全选
        $('.selectAll input').on('ifUnchecked', function (event) {
            $('input').iCheck('uncheck');
        });//反选

        // +----------------------------------------------------------------------
        // | 弹出层
        // +----------------------------------------------------------------------
        $(".dw-dailog").click(function () {
            var dw_url = $(this).attr("dw-url");//URL地址，必填
            var dw_title = $(this).attr("dw-title");//弹出层标题，必填
            var dw_width = $(this).attr("dw-width");//弹出层宽度，如80%或500px；如果没有默认为屏幕宽度的50%
            var dw_height = $(this).attr("dw-height");//弹出层高度，如50%或500px；如果没有默认为屏幕高度的50%
            if (dw_url == undefined) {
                layer.msg("请给button加上dw-url属性");
                return false;
            }
            if (dw_title == undefined) {
                layer.msg("请给button加上dw-title属性");
                return false;
            }
            if (dw_width == undefined) dw_width = '50%';
            if (dw_height == undefined) dw_height = '50%';
            layer.open({
                type: 2,
                title: dw_title,
                shadeClose: true,
                shade: 0.8,
                area: [dw_width, dw_height],
                content: dw_url,
                cancel: function (index, layero) {
                    $(".dw-refresh").trigger('click');
                    location.reload();
                    return false;
                }
            });
        });

        // +----------------------------------------------------------------------
        // | 批量删除
        // +----------------------------------------------------------------------
        $(".batch-delete").click(function () {
            var dw_url = $(this).attr("dw-url");//URL地址，必填
            //获取checkbox[name='like']的值
            var arr = new Array();
            if (dw_url == undefined) {
                layer.msg("请给button加上dw-url属性");
                return false;
            }
            var chk_value = [], data_id;
            $('input[name="empId"]:checked').each(function () {
                chk_value.push($(this).val());
                data_id = chk_value.join(",");//将数组合并成字符串
            });
            if (chk_value.length == 0) {
                layer.msg("请选择要删除的数据!", { anim: 1 });
                return false;
            }
            layer.confirm('确定要删除选中['+chk_value+']的数据吗?', { icon: 3, title: '提示' }, function (index) {
                $.ajax({
                    url: dw_url+'?data_id='+data_id,
                    type: 'DELETE',
                    // data: {"data_id": data_id},
                    success: function(result) {
                        alert("删除成功");
                        location.reload();
                    }
                });


                layer.close(index);
            });
        });

        // +----------------------------------------------------------------------
        // | 删除
        // +----------------------------------------------------------------------
        $(".dw-delete").click(function () {
            var dw_url = $(this).attr("dw-url");//URL地址，必填
            if (dw_url == undefined) {
                layer.msg("请给button加上dw-url属性");
                return false;
            }
            layer.confirm('确定要删除选中[]的数据吗?', { icon: 3, title: '提示' }, function (index) {
                $.ajax({
                    url: dw_url,
                    type: 'DELETE',
                    success: function(result) {
                        alert("删除成功");
                        location.reload();
                    }
                });

                layer.close(index);
            });
        });

        $(".refresh").click(function () {
            var dw_url = $(this).attr("dw-url");//URL地址，必填
            if (dw_url == undefined) {
                layer.msg("请给button加上dw-url属性");
                return false;
            }
            location.href = location.href=dw_url;
        });

    })

</script>

<!-- 设置Excel文件上传 -->
<script>
    layui.use('upload', function() {
        var $ = layui.jquery
            , upload = layui.upload;
        //Excel文件上传
        var uploadInst = upload.render({
            elem: '#operation-excel',
            url: $('#operation-excel').attr("dw-url"),
            auto: true,
            accept: 'file',
            exts: 'xls|xlsx|excel',
            before: function(){
                if ($('#operation-excel').attr("dw-url") == undefined){
                    layer.msg("请给button加上dw-url属性");
                    return false;
                }
            },
            done: function (res) {
                if (res.code == 1) {
                    layer.msg('上传成功',{icon:6});
                }else {
                    layer.msg('上传失败',{icon:6});
                }

            },
            error: function () {
                //演示失败状态，并实现重传
                picText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                picText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            },
        });

    });
</script>
</body>
</html>